﻿Imports System.Data.SqlClient
Imports System.Data

Partial Class _Default
    Inherits System.Web.UI.Page
    Dim cn As New SqlConnection(ConfigurationSettings.AppSettings("conn"))
    Dim catid As String

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Label2.Text = Session("username")
        Try

            Dim str As String = Request.QueryString("id")
            Dim cmd As New SqlCommand("select name from category where categoryid=" + str, cn)
            cn.Open()
            catid = cmd.ExecuteScalar
            Label3.Text = catid
            cn.Close()

            cmd = New SqlCommand("select IMAGEID,title,imageurl from imagetable where categoryid=" + str, cn)

            Dim da As New SqlDataAdapter(cmd)
            cn.Open()
            Dim dt As New DataSet

            da.Fill(dt)

            GridView1.DataSource = dt
            GridView1.DataBind()

        Catch
        End Try



    End Sub

    Protected Sub GridView1_PageIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.PageIndexChanged

    End Sub

    Protected Sub GridView1_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles GridView1.PageIndexChanging
        GridView1.PageIndex = e.NewPageIndex
        GridView1.DataBind()
    End Sub

    Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.SelectedIndexChanged
        Dim str As String = GridView1.Rows(GridView1.SelectedIndex).Cells(0).Text
        Response.Redirect("Details Page.aspx?id=" + str)
    End Sub
End Class
